﻿using EpubFactory.Common;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EpubFactory.Template
{
    public class BookFileCreatorFactory
    {
        public static IEnumerable<IBookFileCreator> GetCreatorList(BookFormat fmt)
        {
            List<IBookFileCreator> result = new List<IBookFileCreator>();

            if (fmt.HasFlag(BookFormat.Mobi))
            {
                result.Add(new MobiCreator() { TemplateFile = Path.Combine("Tpl", "mobi.zip") });
            }
            if (fmt.HasFlag(BookFormat.PlainText))
            {
                result.Add(new TxtCreator());
            }
            if (fmt.HasFlag(BookFormat.Epub201) || result.Count == 0)
            {
                result.Add(new Epub201Creator() { TemplateFile = Path.Combine("Tpl", "default.zip") });
            }
            if (fmt.HasFlag(BookFormat.Epub310) || result.Count == 0)
            {
                result.Add(new Epub310Creator() { TemplateFile = Path.Combine("Tpl", "epub3.zip") });
            }
            return result;
        }
    }
}
